//
//  UILabel+Extension.swift
//  Weibo
//
//  Created by 梁智 on 15/11/23.
//  Copyright © 2015年 lzfree. All rights reserved.
//

import UIKit

extension UILabel {
    
    /// 便利构造函数
    ///
    /// - parameter title:    title
    /// - parameter fontSize: fontSize,默认14号字
    /// - parameter color:    color,默认深灰色
    ///
    /// - returns: UILabel
    /// 参数后面的值是参数的默认值，如果不传递，就使用默认值
    convenience init(title: String, fontSize: CGFloat = 14, color: UIColor = UIColor.darkGrayColor(), screenInset: CGFloat = 0) {
        self.init()
        
        text = title
        textColor = color
        font = UIFont.systemFontOfSize(fontSize)
        numberOfLines = 0;
        
        if screenInset == 0 {
            
            textAlignment = NSTextAlignment.Center
        } else {
            textAlignment = .Left
            preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * screenInset
        }
        
        
    }
}
